<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
include_once("../../config.php");
$connection = mysql_connect(DB_SERVER, DB_USER, DB_PASSWORD);
$dbSelect = mysql_select_db(DB_NAME, $connection);

$fileHandler = fopen("../../design/admin2Codes.csv", "r");
while (!feof($fileHandler)) {
	$line = fgetcsv($fileHandler, 1024);
	$query = sprintf("UPDATE geonames SET admin3_code = '%s' WHERE concat_ws('.', country_code, admin1_code, admin2_code) = '%s'"
		, mysql_escape_string($line[1])
		, mysql_escape_string($line[0])
	);
	$result = mysql_query($query);
}

fclose($fileHandler);
?>
